﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DcsGauges.Gui.Gauges.Interfaces;
using DcsGauges.Shared.DataStructures;

namespace DcsGauges.Data
{
    class DataConnector : IDataConnector
    {
        protected IValueGauge               gauge                   = null;
        protected IDcsA10DataModel          dataModel               = null;
        protected DcsProperty              property                = null;

        public DataConnector(IValueGauge gauge, IDcsA10DataModel dataModel)
        {
            this.gauge              = gauge;
            this.dataModel          = dataModel;
            this.property           = gauge.DataProperty;
        }

        public void Update()
        {
            float value = this.dataModel.GetProperty(this.property);
            gauge.Value = value;
        }
    }

    class DataConnectorContainer : List<IDataConnector>
    {
        public void Update()
        {
            foreach(var connector in this)
            {
                connector.Update();
            }
        }
    }
}
